package cn.com.nes.common.util;

import java.io.StringReader;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;

public class JsonUtil {
	public static Gson gson = new Gson();

	public static Object getObjFromStr(String json, Class class1) {
		Object t = new Object();
		JsonReader reader = new JsonReader(new StringReader(json));
		reader.setLenient(true);
		t = gson.fromJson(reader, class1);
		return t;
	}

	public static  String getStriFromObj(Object t) {
		return gson.toJson(t);
	}
	
	public static void main(String[] args) {
		String data_bin="000000010001111100000000";
		for(int k=0;k<32;k++){
			String tmp_bin = "" ;
			if(data_bin.length()>=8+(k/8)*8){
				tmp_bin = data_bin.substring(0+(k/8)*8,8+(k/8)*8);
				String tmp = tmp_bin.substring(8-(k%8)-1, 8-(k%8)) ;
				System.out.println(tmp_bin+"               "+tmp);
			}
			
		}
		
	}
}
